<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width,user-scalable=0"/>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <script src="__api__/js/fontSize.js"></script>
    <link rel="stylesheet" href="__api__/css/bootstrap.min.css">
    <link rel="stylesheet" href="__api__/css/reset.css">
    <link rel="stylesheet" href="__api__/css/my_main.css">
    <link rel="stylesheet" href="__api__/css/global.css">
    <script src="__api__/js/jquery-3.2.1.min.js"></script>
    <script src="__api__/js/windowOpen.js"></script>

    <style>
        body{
            background-color: #ebebeb;
        }
    </style>
</head>
<body>
<div class="mod_phone">
    <div class="mPhone_tit">
        <div class="container">
            <div class="tel_text">
                <p>
                    <a href="javascript:" class="active">验证原手机号</a>
                    <img src="__api__/images/right.png">
                    <a href="javascript:" class="active">更换手机号</a>
                    <img src="__api__/images/right.png">
                    <a href="javascript:">修改完成</a> </p>
            </div>
        </div>
    </div>
    <div class="phone_form">
        <div class="container">
            <form action="#" class="form-horizontal" onsubmit="return false">
                <div class="form_tel">
                    <input type="tel" class="form-control" placeholder="请输入新的手机号码" id="tel" name="telphone">
                    <a href="#" id="getcode" class="code_btn">获取验证码</a>
                </div>
                <div class="form_num">
                    <input type="text" class="form-control" name="code" placeholder="请输入验证码">
                </div>
                <div class="form_btn">
                    <a href="javascript:" class="open-window-set-indent-fail" id="sub">确认修改</a>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="__assets__/layui.js"></script>
<script src="__assets__/js/jquery.min.js"></script>


<script type="text/javascript">
    
    $(function(){
    	var layer;
    	layui.use('layer', function(){
    		   layer = layui.layer;
    		  
    		  //layer.msg('hello');
    		});     
    	$('#getcode').click(function(){
    		var url="{:url('api/user/getTextValidateCode')}";
    		var telphone=$('#tel').val();
    		//console.log(telphone);
    		var data={telphone:telphone};
    		$.get(url,data,function(res){
    			var obj=eval('(' + res +')');
    			var status=obj.status;
    			var info=obj.info;
    			if(status==200){
    				layer.msg(info,{icon:6});
    			}else if(status==-1){
    				layer.msg(info,{icon:5});
    			}else if(status==414){
    				layer.msg(info,{icon:5});
    			}else{
    				layer.msg(info,{icon:5});
    			}
    		})
    	});
    	$('#sub').click(function(){
    		var url="{:url('api/Userinfo/modphone2')}";
    		var data= $("form").serialize();
    		$.post(url,data,function(res){
    			var obj=eval('('+ res +')');
    			var status=obj.status;
    			var info=obj.info;
    			if(status==0){
    				layer.msg(info,{icon:5});
    			}else if(status==400){
    				layer.msg(info,{icon:5});
    			}else if(status==401){
    				layer.msg(info,{icon:5});
    			}else if(status==-1){
        				layer.msg(info,{icon:5});
    			
    			}else{
    				layer.msg(info,{icon:6},function(){
    					window.location.href=obj.data;
    				});
    			}
    		})
    	})
    	
    })

</script>

</body>
</html>